package com.fin.zw.intelligentbot.entity;

import com.fin.zw.intelligentbot.enums.SourceType;
import com.fin.zw.intelligentbot.enums.Whether;
import lombok.Data;
import org.hibernate.annotations.Table;

import javax.persistence.*;
import java.util.Set;

@Data
@Table(appliesTo = "line_info",comment="线路信息表")
@Entity
public class LineInfo extends BaseEntity{

    @Column(columnDefinition = "varchar(100) COMMENT '名称'")
    private String name;

    @Column(columnDefinition = "varchar(20) COMMENT '线路编号'")
    private String code;

    @Column(columnDefinition = "varchar(50) COMMENT '服务地址'")
    private String sever;

    @Column(columnDefinition = "varchar(20) comment '来源方向(企业方还是超级管理)'")
    @Enumerated(EnumType.STRING)
    private SourceType source;

    @Column(columnDefinition = "varchar(30) COMMENT '账号'")
    private String account;

    @Column(columnDefinition = "varchar(20) COMMENT '密码'")
    private String password;

    @Column(columnDefinition = "varchar(20) comment '是否注册'")
    @Enumerated(EnumType.STRING)
    private Whether isRegister;

    @Column(columnDefinition = "int(8) COMMENT '端口'")
    private Integer port;

    @Column(columnDefinition = "varchar(100) COMMENT '前缀'")
    private String prefix;

    @Column(columnDefinition = "int(8) COMMENT '并发数量'")
    private Integer concurrencyCount;

    @Column(columnDefinition = "int(8) COMMENT '使用数量'")
    private Integer usedCount;

    @Column(columnDefinition = "varchar(100) COMMENT '供应商'")
    private String provider;

    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinTable(name = "line_company", joinColumns = @JoinColumn(name = "line_id"), inverseJoinColumns = @JoinColumn(name = "company_id"))
    private Set<Company> companies;
}
